<?php

declare(strict_types=1);
/**
 * This file is part of Hyperf.
 *
 * @link     https://www.hyperf.io
 * @document https://doc.hyperf.io
 * @contact  group@hyperf.io
 * @license  https://github.com/hyperf/hyperf/blob/master/LICENSE
 */

use Hyperf\HttpServer\Router\Router;

Router::addRoute(['GET', 'POST', 'HEAD'], '/', 'App\Controller\IndexController@index');

// 前台
Router::addGroup('/api', function () {
    Router::post('/login', 'App\Controller\Api\UserController@login');
    Router::post('/register', 'App\Controller\Api\UserController@register');
    Router::get('/sum', 'App\Controller\Api\UserController@sum');
});

Router::addGroup('/api', function () {
    Router::get('/user', 'App\Controller\Api\UserController@user');
}, ['middleware' => [\Phper666\JWTAuth\Middleware\JWTAuthMiddleware::class, \App\Middleware\AuthUserMiddleware::class]]);


// 后台
Router::addGroup('/admin', function () {
    Router::post('/login', 'App\Controller\Admin\AdminController@login');
    Router::post('/register', 'App\Controller\Admin\AdminController@register');
});

Router::addGroup('/admin', function () {
    Router::get('/admin', 'App\Controller\Admin\AdminController@admin');
}, ['middleware' => [\Phper666\JWTAuth\Middleware\JWTAuthMiddleware::class, \App\Middleware\AuthAdminMiddleware::class]]);

